Skip to main content

Arrow Function

Features of Arrow Function

Lexical this

  • The biggest difference from normal functions is how arrow functions handle this.
  • In normal functions, this depends on how the function is called (dynamic binding).
  • In arrow functions, this is taken from the surrounding scope (lexical binding).
  • Because of this, you cannot change this using call(), apply(), or bind() on an arrow function.

Cannot Be Used as Constructors

Arrow functions cannot be used with new.

They don’t have a prototype property, so you can’t create objects from them.

const Student = (name) => {
this.name = name;
};

const s1 = new Student("Masum"); // ❌ TypeError: Student is not a constructor

No arguments Object

In normal functions, you can use the special arguments object. In arrow functions, arguments is not available (they inherit from parent scope if used).